package com.english.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.english.entity.RechargeProcessLog;
import com.english.vo.RechargeProcessLogVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 充值处理日志Mapper接口
 */
@Mapper
public interface RechargeProcessLogMapper extends BaseMapper<RechargeProcessLog> {
    
    /**
     * 获取充值处理日志列表（包含学生和管理员信息）
     *
     * @return 处理日志列表
     */
    @Select("SELECT DISTINCT " +
            "rpl.id, " +
            "sr.user_id as studentId, " +
            "u1.name as studentName, " +
            "u1.phone as studentPhone, " +
            "rpl.processed_amount as rechargeAmount, " +
            "rpl.admin_id as adminId, " +
            "u2.name as adminName, " +
            "rpl.process_time as processTime, " +
            "rpl.hours_added as hoursAdded, " +
            "rpl.class_id as classId, " +
            "cc.class_name as className, " +
            "rpl.process_notes as processNotes " +
            "FROM recharge_process_log rpl " +
            "LEFT JOIN student_recharge sr ON rpl.recharge_id = sr.id " +
            "LEFT JOIN user u1 ON sr.user_id = u1.id " +
            "LEFT JOIN user u2 ON rpl.admin_id = u2.id " +
            "LEFT JOIN course_class cc ON rpl.class_id = cc.id " +
            "ORDER BY rpl.process_time DESC")
    List<RechargeProcessLogVO> getRechargeProcessLogs();
} 